package com.monkeygroup.mygoplus.common.DefinedView;

import android.app.Activity;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.widget.EditText;

import com.monkeygroup.mygoplus.commit.thing.vo.PropertyCommitVO;
import com.monkeygroup.mygoplus.common.utils.LocalInfo;
import com.monkeygroup.mygoplus.user.vo.IdentifyVO;

/**
 * Created by cumt on 2017/6/30.
 */

public class IdentifyTextWatcher implements TextWatcher {

    private EditText mEditText;
    private CharSequence mCharSequence;
    private Activity activity;
    private IdentifyVO requestVO;
    private int index;

    public IdentifyTextWatcher(Activity activity, EditText e, IdentifyVO vo, int index) {
        mEditText = e;
        this.activity=activity;
        this.requestVO=vo;
        this.index=index;
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        mCharSequence = s;
    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
       // Log.e("String.t.getText())",""+String.valueOf(mEditText.getText()));
        if(index==1){
            requestVO.setAccount(String.valueOf(mEditText.getText()));
        }
        else if(index==2){
            requestVO.setPasswd(String.valueOf(mEditText.getText()));
        }
        else if(index==3){
            requestVO.setFirstname(String.valueOf(mEditText.getText()));
        }
        else if(index==4){
            requestVO.setLastname(String.valueOf(mEditText.getText()));
        }
        else if(index==5){
            requestVO.setName(String.valueOf(mEditText.getText()));
        }
        else if(index==6){
            if("男".equals(String.valueOf(mEditText.getText()))){
                requestVO.setGender(1);
            }
            else{
                requestVO.setGender(0);
            }

        }
        else if(index==7){
            requestVO.setMobile(String.valueOf(mEditText.getText()));
        }
        else if(index==8){
//            requestVO.sett(Integer.parseInt(String.valueOf(mEditText.getText())));
        }
        else if(index==9){
            requestVO.setAddr(String.valueOf(mEditText.getText()));
        }
        else if(index==10){
            requestVO.setAlley(String.valueOf(mEditText.getText()));
        }
        else if(index==11){
//            requestVO.setla(String.valueOf(mEditText.getText()));
        }
        else if(index==12){
            requestVO.setGate(String.valueOf(mEditText.getText()));
        }
        else if(index==13){
//            requestVO.setst(String.valueOf(mEditText.getText()));
        }
        else if(index==14){
//            requestVO.seto(Integer.parseInt(String.valueOf(mEditText.getText())));
        }
        else if(index==15){
         //   requestVO.setServer_addr1(Integer.parseInt(String.valueOf(mEditText.getText())));
        }
        else if(index==16){
         //   requestVO.setServer_addr2(Integer.parseInt(String.valueOf(mEditText.getText())));
        }
        else if(index==17){
            requestVO.setShopname(String.valueOf(mEditText.getText()));
        }
        else if(index==18){
            requestVO.setCerti1(String.valueOf(mEditText.getText()));
        }
        else if(index==19){
//            requestVO.setCerti2(String.valueOf(mEditText.getText()));
        }
        else if(index==20){
            requestVO.setCompanyaddr(String.valueOf(mEditText.getText()));
        }
        else if(index==21){
            requestVO.setCom_alley(String.valueOf(mEditText.getText()));
        }
        else if(index==22){
//            requestVO.setCom_alley(String.valueOf(mEditText.getText()));
        }
        else if(index==23){
            requestVO.setCom_gate(String.valueOf(mEditText.getText()));
        }
        else if(index==24){
//            requestVO.setCom_st(String.valueOf(mEditText.getText()));
        }
        else if(index==25){
//            requestVO.seto(String.valueOf(mEditText.getText()));
        }else if(index==26){
            requestVO.setCommunityname(String.valueOf(mEditText.getText()));
        } else if(index==27){
        requestVO.setEmail(String.valueOf(mEditText.getText()));
    }
        Log.e("getAccountgetAccount==",""+requestVO.getAccount());
        LocalInfo.saveIdentify(activity,requestVO);
    }

    @Override
    public void afterTextChanged(Editable s) {

    }
}
